﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Windows;
using TfsExtensions.Build.Controls;
using System.Windows.Forms;
using TfsExtensions.Build.Activities.Entities;
using System.Collections.ObjectModel;

namespace TfsExtensions.Build.ActivityLibrary.Tests
{
    [TestClass]
    public class AssemblyMetadataEditorTest
    {
        [TestMethod]
        public void InvokeMetadataEditor()
        {
            System.Windows.Forms.Application.EnableVisualStyles();
            System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);
            var metadata = new AssemblyMetadata();
            var assemblySettingCollection = new Collection<AssemblySettings>();
            var assemblyApplicationDetails = new AssemblyApplicationSettings()
                                                {
                                                    ApplicationDescription = "Application description",
                                                    ApplicationName = "Application Name",
                                                    CompanyName = "Compnay Name",
                                                    IsAssemblyMetadataSelected = true
                                                };
            var signingDetails = new AssemblySigningSettings()
                                                {
                                                    IsAssemblySigning = true,
                                                    IsDelaySigned = false,
                                                    SignKeyContent = new byte[] { 1, 2 },
                                                    StrongKeyName = "KeyContainerName"
                                                };

            var versionDetails = new AssemblyVersionSettings()
                                                {
                                                    IsAssemblyVersionSelected = true,
                                                    Build = "1",
                                                    Major = "1",
                                                    Minor = "0",
                                                    Revision = "0"
                                                };

            var fileVersionDetails = new AssemblyFileVersionSettings()
                                                {
                                                    Major = "1",
                                                    Minor = "0"
                                                };

            assemblySettingCollection.Add(
                new AssemblySettings()
                {
                    AssemblyMetadataDetails = assemblyApplicationDetails,
                    AssemblySigningDetails = signingDetails,
                    AssemblyVersionDetails = versionDetails,
                    FileVersionDetails = fileVersionDetails,
                    FileVersion = fileVersionDetails.ToString(),
                    IsMetadataEnabled = assemblyApplicationDetails.IsAssemblyMetadataSelected.ToString(),
                    IsSigningEnabled = (signingDetails.IsAssemblySigning & signingDetails.IsDelaySigned).ToString(),
                    MetadataDetails = assemblyApplicationDetails.ToString(),
                    SigningDetails = signingDetails.ToString(),
                    Version = versionDetails.ToString(),
                }
                );

            metadata.Metadata = assemblySettingCollection;
        }
    }
}
